<?php defined('SYSPATH') or die('No direct access allowed.');

class Controller_Service extends Controller
{    
    public function action_email(){
	if(Request::$initial->is_ajax()){
	    $response = array('status' => 'ok');
	    
	    try
	    {
                $message = View::factory('email/order')
                                ->set('data', $_POST)
                                ->render();


                Email::send('maxdanilkin@mail.ru',
                            'maxdanilkin@mail.ru',
                            'Заказ с сайта',
                            $message,
                            true);    
	    }
	    catch(Exception $e)
	    {
		$response['status'] = 'error';
		$response['error'] = $e->getMessage();
	    }    
	    $this->response->body(json_encode($response));
	}
    }



}